//
//  Color.swift
//  MagaCore
//
//  Created by MrMessy on 2023/4/29.
//

import Foundation
typealias JSONDictionary = [String: Any]

extension JSONDictionary {
    func ht_urls() -> [HTServer] {
        var var_dubList: [String] = []
        var var_subList: [String] = []
        
        for (key, value) in self {
            if key.contains("dub6"), let url = value as? String, !url.isEmpty {
                var_dubList.append(url)
            }
            if key.contains("ost6"), let url = value as? String, !url.isEmpty {
                var_subList.append(url)
            }
        }
        
        var var_dubServerList: [HTServer] = var_dubList.map { HTServer(var_name: "DUB", var_url: $0) }
        var var_subServerList: [HTServer] = var_subList.map { HTServer(var_name: "SUB", var_url: $0) }
        
        var var_resList = var_dubServerList + var_subServerList
        if !var_resList.isEmpty {
            var_resList[0].var_selected = true
        }
        
        return var_resList
    }
}
